package com.hxkj.service;

import com.github.pagehelper.PageInfo;
import com.hxkj.domain.po.AuthRole;
import com.platform.common.domain.result.ResultDataStruct;
import com.platform.common.domain.result.ResultMessageStruct;
import com.platform.common.domain.to.PageTo;

/**
 * 权限mapper
 * <p>
 * Created by chenfangzhou on 2018/5/23.
 */
public interface AuthRoleService {

    /**
     * 保存用户信息
     *
     * @param authRole
     * @return
     * @throws Exception
     */
    ResultMessageStruct saveAuthRole(AuthRole authRole) throws Exception;

    /**
     * 根据用户ID获取用户姓名
     *
     * @param
     * @return
     * @throws Exception
     */
    ResultDataStruct<AuthRole> getAuthRole(AuthRole authRole) throws Exception;


    /**
     * 获取符合条件的所有用户
     *
     * @return
     * @throws Exception
     */
    PageInfo<AuthRole> getRoleList(AuthRole authRole, PageTo pageParam) throws Exception;

    /**
     * 获取符合条件的所有用户
     *
     * @return
     * @throws Exception
     */
    PageInfo<AuthRole> getAuthRoleBySlave(AuthRole authRole, PageTo pageParam) throws Exception;


    /**
     * 从缓存中获取数据
     *
     * @param roleId
     * @return
     * @throws Exception
     */
    //@Cached(name="authRoleCache", key="#authRoleId", expire = 3600,cacheType = CacheType.REMOTE)
    AuthRole getAuthRoleFromCache(Long roleId) throws Exception;


    /**
     * 更新用户缓存
     *
     * @param authRole
     */
    //@CacheUpdate(name="authRoleCache.", key="#authRole.authRoleId", value="#authRole")
    ResultMessageStruct updateAuthRole(AuthRole authRole);

    /**
     * 删除用户缓存
     *
     * @param authRole
     */
    //  @CacheInvalidate(name="authRoleCache.", key="#authRoleId")
    ResultMessageStruct deleteAuthRole(AuthRole authRole);


    /**
     * 从缓存中获取数据
     *
     * @param roleId
     * @return
     * @throws Exception
     */
    //  @Cached(name="authRoleCache", key="#authRoleId", expire = 3600,cacheType = CacheType.REMOTE)
    //   @CacheRefresh(refresh = 1800, stopRefreshAfterLastAccess = 3600, timeUnit = TimeUnit.SECONDS)
    AuthRole getAuthRoleRefresh(Long roleId) throws Exception;

    /**
     * 获取改角色已分配的功能/全部功能列表
     *
     * @param authRole 角色
     * @return 已分配的功能/全部功能列表
     * @throws Exception
     */
    // @Cached(name="roleFunctionCache", key="#roleId", expire = 3600,cacheType = CacheType.REMOTE)
    ResultDataStruct getFunction(AuthRole authRole) throws Exception;

    /**
     * 获取改角色已分配的功能/全部功能(树形结构)
     *
     * @param authRole 角色
     * @return 已分配的功能/全部功能(树形结构)
     * @throws Exception
     */
    //  @Cached(name="roleFunctionCache", key="#roleId", expire = 3600,cacheType = CacheType.REMOTE)
    ResultDataStruct getFunctions(AuthRole authRole) throws Exception;

    /**
     * 为该角色分配功能
     *
     * @param authRole 角色
     * @return 已分配的功能/全部功能
     * @throws Exception
     */
    //   @CacheEvict(value="roleFunctionCache", key="#roleId",allEntries=true)
    void saveAllocationFunction(AuthRole authRole) throws Exception;
}
